﻿using Architecture.API.Application.Command.ProvinceCommand;
using Architecture.Domain;
using Architecture.Domain.Service.ProvinceServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.ProvinceHandler
{
    /// <summary>
    /// 省份查询命令处理器
    /// </summary>
    public class ProvinceSearchCommandHandler : IRequestHandler<ProvinceSearchCommand, List<Province>>
    {

        /// <summary>
        /// 省份业务逻辑接口
        /// </summary>
        private readonly IProvinceService _provinceService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="provinceService">省份业务逻辑接口</param>
        public ProvinceSearchCommandHandler(IProvinceService provinceService)
        {
            _provinceService = provinceService;
        }

        /// <summary>
        /// 处理查询省份命令
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回省份查询信息</returns>
        public async Task<List<Province>> Handle(ProvinceSearchCommand request, CancellationToken cancellationToken)
        {
            return await _provinceService.GetListProvincesAsync();
        }
    }
}
